﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace HashCalculator.Converters
{
    [ValueConversion(typeof(bool), typeof(string))]
    class BooleanInvertConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Invert(value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Invert(value);
        }

        static object Invert(object o)
        {
            if (o is bool)
            {
                return !(bool)o;
            }
            return Binding.DoNothing;
        }
    }
}
